package cn.marinda.listener;

import cn.marinda.entity.ServerPlugin;
import cn.marinda.gui.impl.DownloadServerDiaLogImpl;
import cn.marinda.gui.impl.OnlinePluginFilesHelperImpl;
import cn.marinda.util.ServerUtils;
import cn.marinda.util.SwingUtils;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashSet;
import java.util.Set;

/**
 * 下载在线插件事件
 *
 * @author marinda
 * @date 2022/07/29
 */
public class DownloadOnlinePluginEvent implements ActionListener {

    private Set<String> pluginList;
    private JButton button;

    /**
     * 下载在线插件事件
     *
     * @param pluginList 插件列表
     * @param button     按钮
     */
    public DownloadOnlinePluginEvent(Set<String> pluginList,JButton button){
        this.pluginList = pluginList;
        this.button = button;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
//        关闭窗体
        OnlinePluginFilesHelperImpl.instance.close();
        SwingUtils.downloadDialog = new DownloadServerDiaLogImpl(pluginList);
        SwingUtils.downloadDialog.open();
    }
}
